package com.hcbd.tdwt.ui.setting.xingyu.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RelativeLayout;


import com.hcbd.tdwt.R;
import com.hcbd.tdwt.base.BaseActivity;
import com.hcbd.tdwt.base.Constant;
import com.hcbd.tdwt.base.bd.BdToolFactory;
import com.hcbd.tdwt.util.SharedPreferencesUtil;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.CheckedChange;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

@SuppressLint("NonConstantResourceId")
@EActivity(R.layout.activity_position_set)
public class PositionSetActivity extends BaseActivity {
    @ViewById
    RelativeLayout rnssSetRL;
    @ViewById
    RadioButton phonePosRB,bdPosRB;
    @ViewById
    RadioButton degreeMinutesSecondsRB,degreeFormatRB;
    @ViewById
    LinearLayout bdRNssLL,posSettingLL;
    SharedPreferencesUtil sp;
    @AfterViews
    protected void init() {

        sp=new SharedPreferencesUtil(this);
        String mode=sp.getAttribute(Constant.POSITION_MODE);
        if(Constant.PHONE_POS.equals(mode)){
            phonePosRB.setChecked(true);
        }else if(Constant.BD_POS.equals(mode)){
            bdPosRB.setChecked(true);
        }
        int format=sp.getAttributeInt(Constant.LATITUDE_AND_LONGITUDE_FORMAT);
        if(Constant.DEGREE_MINUTES_SECONDS_FORMAT==format){
            degreeMinutesSecondsRB.setChecked(true);//度分秒格式
        }else if(Constant.DEGREE_FORMAT==format){
            degreeFormatRB.setChecked(true);//度数格式
        }
        if(BdToolFactory.MOBILE_PHONE_TYPE==BdToolFactory.SATELLITE_MOBILE_PHONE){
            bdRNssLL.setVisibility(View.GONE);
            posSettingLL.setVisibility(View.GONE);
        }
    }
    @CheckedChange
    void phonePosRB(boolean b){
        if(b){
            sp.addAttribute(Constant.POSITION_MODE,Constant.PHONE_POS);
        }
    }

    @CheckedChange
    void bdPosRB(boolean b){
        if(b){
            sp.addAttribute(Constant.POSITION_MODE,Constant.BD_POS);
        }
    }
    @CheckedChange
    void degreeMinutesSecondsRB(boolean b){
        if(b){
            sp.addAttribute(Constant.LATITUDE_AND_LONGITUDE_FORMAT,Constant.DEGREE_MINUTES_SECONDS_FORMAT);
        }
    }
    @CheckedChange
    void degreeFormatRB(boolean b){
        if(b){
            sp.addAttribute(Constant.LATITUDE_AND_LONGITUDE_FORMAT,Constant.DEGREE_FORMAT);
        }
    }

    @Click
    void rnssSetRL(){
        Intent intent=new Intent();
        intent.setClass(this, RnssFrequencyActivity_.class);
        startActivity(intent);
    }
    @Click
    void headLeft(){
        finish();
    }
}
